package com.demo125_验证回文串;

import java.util.Locale;

public class Solution {
    public static void main(String[] args) {
        boolean palindrome = isPalindrome("abb");
        System.out.println(palindrome);

    }
    public static boolean isPalindrome(String s) {
        StringBuilder builder = new StringBuilder();
        char c ;
        if (s.length()==0){
            return true;
        }
        for (int i = 0; i < s.length(); i++) {
            c=s.charAt(i);
            if (c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122){
                builder.append(c= (c>=65&&c<=90)? (char) (c + 32) :c); // 这里是把这个大写字母转小写字母.  应该是有这个对应的api

            }
        }

        if (builder.length()==0){
            return true;
        }
        String sb = builder.toString();
        int len = sb.length();
        for (int i = 0; i < len/2+1; i++) {
            if (sb.charAt(i)!=sb.charAt(len-1-i)&&i<=(len-i-1)){
                return false;
            }
        }

        return true;

    }
}
